package com.decent.ejfadmin.product.dao;

import java.lang.reflect.Method;
import java.math.BigDecimal;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.decent.ejfadmin.common.bean.SupplyProductPrice;

/**
 * 产品价格sql管理
 *
 * @author 王元鑫
 * @date 2016/11/22
 */
@Mapper
@Repository
public interface PriceDao {
	/**
	 * 查询会员销卡价格
	 *
	 * @param modelId 价格模板Id
	 * @param face    卡面值
	 * @param type    运营商
	 * @param area    卡地区
	 * @param speed   销卡速度
	 * @return 价格
	 */
	@Select("SELECT " + " mo.state modelState, " + " p.state, " + " m.max_price maxPrice, " + " m.min_price minPrice "
			+ "FROM " + " yuhuang_supply_product p, " + " yuhuang_supply_model_price_map m, "
			+ " yuhuang_supply_model mo " + "WHERE " + " p.id = m.product_id " + "AND m.model_id = mo.id "
			+ "AND p.area = #{area} " + "AND p.face = #{face} " + "AND p.product_type = #{type} "
			+ "and m.speed = #{speed}  " + "AND m.model_id = #{modelId}")
	SupplyProductPrice querySupCardPrice(@Param("modelId") Integer modelId, @Param("face") BigDecimal face,
			@Param("type") Integer type, @Param("area") String area, @Param("speed") Integer speed);

	public static void main(String[] args) {
		Method[] methods = PriceDao.class.getMethods();
		for (int i = 0; i < methods.length; i++) {
			System.out.println(methods[i]);
			if ("querySupCardPrice".equals(methods[i].getName())) {
				Select annotation = methods[i].getAnnotation(Select.class);
				System.out.println(annotation.value()[0]);
			}
		}
	}

}
